package com.goldenautumn.prefabricate.activity.mine.order

import androidx.fragment.app.Fragment
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.databinding.ActivityAfterSalesBinding
import com.goldenautumn.prefabricate.utils.Constants
import com.gyf.immersionbar.ImmersionBar
import kotlinx.coroutines.isActive
import qncx.external.common.base.BaseActivity
import qncx.external.common.widget.tabLayout.ViewPager2Adapter

class AfterSalesActivity : BaseActivity<ActivityAfterSalesBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_after_sales

    override suspend fun main() {
        ImmersionBar.setTitleBar(this, mBinding.toolbar)
        initToolbarNav(mBinding.toolbar)

        var titles = arrayListOf(getString(R.string.order_status_all_after),getString(R.string.order_status_processing))
        var fragment = ArrayList<Fragment>()
        fragment.add(AfterSalesFragment.newInstance(Constants.ORDER_TYPE_ALL))
        fragment.add(AfterSalesFragment.newInstance(Constants.ORDER_TYPE_PENDING))

//        mBinding.viewPage.offscreenPageLimit = 3
        mBinding.viewpage.adapter = ViewPager2Adapter(supportFragmentManager,lifecycle,fragment)
        mBinding.tabLayout.setSnapOnTabClick(true)
        mBinding.tabLayout.setViewPager2(mBinding.viewpage,titles)

        while (isActive) {
            events.receive()
        }
    }


}